<?php
namespace app\admin\controller;
class Basic extends \think\Controller
{
   const SESSION_AUTH_KEY = "AUTH_ACCOUNT";
   const SESSION_LEAVE ="LEAVE";
   const SESSION_ID="ID";
    
   public function _initialize() {
        parent::_initialize();
        if (!session(Basic::SESSION_AUTH_KEY)){
           $this->redirect("/admin/Login/index.html");
        } else {
//           $this->redirect("/admin/Index/index.html");
            $this->assign('adminName',  \think\Session::get(Basic::SESSION_AUTH_KEY));
        }
   }
   
   public function delPhoto($photo){
       try{
           $photo = substr($photo,1);
           if(file_exists($photo)){
               unlink($photo);
           }
       } catch (Exception $ex) {
           return null;
       }
      
   }


   public function urlChange(){
           $getData = filter_input_array(INPUT_GET);
           $url = $getData["U"];
           return $this->redirect($url);
    }
    
    //制作菜单，并且确定展开项
    public function menu($fid=0,$sid=0){
        $menus = \think\Loader::model('Menus','logic');
        
        $leave = session(Basic::SESSION_LEAVE);
        $m = $menus->makeMenus($fid,$sid,$leave);
        $this->assign("menu",$m);
    }
}